// const WxApiRoot = 'http://114.55.95.151:10001/wx';
const WxApiRoot = 'https://zhsqht.fjclound.com/wx';
// const WxApiRoot = 'https://zhsqht.linjun.xyz/wx';
// const WxApiRoot = '/api/prod-api/wx';
const requestWx = (url, method, data) => {
	let _url = WxApiRoot + url
	return new Promise((resolve, reject) => {
		let tokenOpenid = uni.getStorageSync("userInfo").weixinOpenid;

		uni.request({
			url: _url,
			method: method,
			data: data,
			header: {
				"token-openid": tokenOpenid,
				"Content-Type": "application/json"
			},
			success(res) {
				resolve(res)
			},
			fail(error) {
				reject(error)
			},
			complete(comp) {
				// 加载完成
			}
		})
	})
}
module.exports = {
	requestWx,
	// 获取公告广告新闻
	async getNotice(data) {
		return requestWx("/community/notice/list", "GET", data)
	},
	// 获取轮播图列表
	async getDiagram(data) {
		return requestWx("/community/diagram/list", "GET", data)
	},
	// 获取轮播图详情
	async getDiagramDetail(data) {
		return requestWx("/community/diagram/getInfo", "GET", data)
	},
	// 获取公告广告新闻详细信息
	async getNoticeDetails(data) {
		return requestWx("/community/notice/getInfo", "GET", data)
	},
	// 获取意见反馈列表
	async getFeedback(data) {
		return requestWx("/community/complain/list", "GET", data)
	},
	// 获取意见反馈详情
	async getFeedbackDetails(data) {
		return requestWx("/community/complain/getInfo", "GET", data)
	},
	// 获取疫情服务
	// ​/epidemicSituation​/list
	// async getepidemic(data) {
	// 	return requestWx("/epidemicSituation/list", "GET", data)
	// },
	async getepidemic(data) {
		return requestWx("/epidemicSituation/jsons", "GET", data)
	},
	// 添加意见反馈
	async addFeedback(data) {
		return requestWx("/community/complain/add", "POST", data)
	},
	// 修改意见反馈
	async editFeedback(data) {
		return requestWx("/community/complain/edit", "PUT", data)
	},
	// 删除意见反馈
	async delFeedback(id) {
		return requestWx("/community/complain/remove/"+id, "DELETE")
	},
	// 新增用户信息
	async getUserAdd(data) {
		return requestWx("/community/user", "GET", data)
	},
	//获取网页授权地址
	async getOauth2Url() {
		return requestWx("/mp/oauth2/geturl", "GET")
	},
	// wx登录获取用户信息 /prod-api/wx/mp/login/{code}
	async getCodeLogin(data) {
		return requestWx("/mp/login", "GET", data)
	},
	//根据字典类型查询字典数据信息
	async getSystemUserType(data) {
		return requestWx("/system/dict/data/type", "GET", data)
	},
	//获取活动列表
	async getActivity(data) {
		return requestWx("/community/exercise/list", "GET", data)
	},
	//我的活动列表
	async getmyActivity(data) {
		return requestWx("/community/exercise/myExercise", "GET", data)
	},
	//活动详情
	async getActivityDetails(data) {
		return requestWx("/community/exercise/getInfo", "GET", data)
	},
	//行程列表
	async getTrip(data) {
		return requestWx("/community/trip/list", "GET", data)
	},
	//获取活动记录列表
	async getAcyivityRecord(data) {
		return requestWx("/community/eserciseHistory/list", "GET", data)
	},
	//立即报名
	async getJoinAcyivity(data) {
		return requestWx("/community/eserciseHistory/add", "POST", data)
	},
	//取消报名
	async getCancelAcyivity(id) {
		return requestWx("/community/eserciseHistory/remove/"+id, "DELETE")
	},
	// 获取访客列表
	async getVisitor(data) {
		return requestWx("/community/visit/list", "GET", data)
	},
	// 获取行程详情
	async getmyTrip(data) {
		return requestWx("/community/trip/getInfo", "GET", data)
	},
	//新增行程
	async addTrip(data) {
		return requestWx("/community/trip/add", "POST", data)
	},
	//修改行程
	async enitTrip(data) {
		return requestWx("/community/trip/edit", "PUT", data)
	},
	//删除行程
	async deletTrip(id) {
		return requestWx("/community/trip/remove/"+id, "DELETE")
	},
	// 获取访客详情
	async getVisitorDetails(data) {
		return requestWx("/community/visit/getInfo", "GET", data)
	},
	// 新增访客信息
	async addVisitor(data) {
		return requestWx("/community/visit/add", "POST", data)
	},
	// 修改访客信息
	async editVisitor(data) {
		return requestWx("/community/visit/edit", "PUT", data)
	},
	// 删除访客信息
	async delVisitor(id){
		return requestWx("/community/visit/remove/"+id,"DELETE")
	},
	//新增用户
	async getUserAdd(data) {
		return requestWx("/community/user/add", "POST", data)
	},
	//编辑修改用户信息
	async getUserEdit(data) {
		return requestWx("/community/user/edit", "PUT", data)
	},
	//获取个人信息--openid /prod-api/wx/community/user/list
	async getUserInfoByOpenid(data) {
		return requestWx("/community/user/list", "GET", data)
	},
	// 获取个人信息--id
	async getUserInfoById(data) {
		return requestWx("/community/user/getInfo", "GET", data)
	},
	//新增房屋 /prod-api/wx/community/house/add
	async getHouseAdd(data) {
		return requestWx("/community/house/add", "POST", data)
	},
	// ​修改房屋/prod-api​/wx​/community​/house​/edit
	async getHouseEdit(data) {
		return requestWx("/community/house/edit", "PUT", data)
	},
	//我的房屋 /prod-api/wx/community/house/myhouse
	async getMyhouse(data) {
		return requestWx("/community/house/myhouse", "GET", data)
	},
	//删除房屋 /prod-api/wx/community/house/remove
	async getHouseRemove(data) {
		return requestWx(`/community/house/remove/${data.id}`, "DELETE")
	},
	// 获取小区列表/prod-api/wx/community/housing/list
	async getHouselist() {
		return requestWx("/community/housing/list", "GET")
	},
	// 获取房屋信息详情/prod-api/wx/community/house/getInfo
	async getHouseInfo(data) {
		return requestWx("/community/house/getInfo", "GET",data)
	},
	//提交健康填报
	async healthAdd(data) {
		return requestWx("/community/report/add", "POST", data)
	},
	//判断用户是否提交
	async yeshealth(data) {
		return requestWx("/community/report/judg", "GET",data)
	},
	//获取健康填报列表
	async getReport(data) {
		return requestWx("/community/report/list", "GET",data)
	},
	// 获取健康报告详情/prod-api/wx/community/report/getInfo
	async getReportInfo(data) {
		return requestWx("/community/report/getInfo","GET",data)
	},
	//删除健康报告 /prod-api/wx/community/report/remove/{id}
	async getReportRemove(data) {
		return requestWx(`/community/report/remove/${data.id}`, "DELETE")
	}
}
